package com.cloudcentral.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cloudcentral.entity.RadioDevice;
import com.cloudcentral.exception.FailureException;
import com.cloudcentral.mapper.RadioDeviceMapper;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 台站设备信息上报记录表 服务实现类
 * </p>
 *
 * @author Administrator
 * @since 2023-11-22
 */
@Service
public class RadioDeviceService extends ServiceImpl<RadioDeviceMapper, RadioDevice> {

  @Transactional(rollbackFor = {Exception.class})
  @GlobalTransactional(rollbackFor = {Exception.class})
  public RadioDevice submit(RadioDevice radioDevice) throws Exception {
    if (radioDevice.getRadioId() == null) throw new FailureException("缺少台站ID");
    else {
      save(radioDevice);
      return baseMapper.selectDeviceInfo(radioDevice.getRadioId());
    }
  }
}
